Skip to content

Conversation

morr0ne
Copy link
Contributor

@morr0ne morr0ne commented Aug 25, 2025

As the title says. This PR splits up the auxv header into its own module. This seems trivial but it has ended up helping me a lot in some projects for several reasons.

  • Having a clear separation of the module instead of the the constants living in the general module allows me to more clearly see what's actually part of the auxv. Unlike other definitions, the auxv don't have any kind of differentiating prefix but just start with AT_ which is also used by other consts. A good way to illustrate the point is the counter example of the magic.h consts which all have the MAGIC suffix so they are easy to differentiate
  • Makes it easier to differentiate between architectures since not all architectures have the same auxv, so it makes it relatively trivial to compare them
  • Overall it's a much nicer way of accessing these variables since it clearly denotes where they are coming from and I can use them with a qualified auxv::AT_ import

Implementing this made me realize that there are other modules bunched up in the general.h that could ideally be separate modules, but it would get really crowded if all of those modules had their own feature. Not sure if it's worth opening an issue to discuss that.

@sunfishcode
Copy link
Owner

This sounds reasonable. The CI failure looks to be due to the generated files not being updated. Could you run the gen program and update this PR?

Another reason a lot of things are bunched in the general module is that Linux headers often pull in other Linux headers, so it's difficult to get clearly scoped modules that just have headers for one purpose and not also all their transitive header dependencies. Because if every module has its dependencies, we'd end up with a lot of duplication. I imagine one way forward is to make more use of bindgen's ability to filter out symbols by things like prefix names. That won't always work (as in the AT_ case here), but could help in many cases.

@morr0ne
Copy link
Contributor Author

morr0ne commented Sep 9, 2025

This sounds reasonable. The CI failure looks to be due to the generated files not being updated. Could you run the gen program and update this PR?

I did try but I must be doing something wrong or there is some inconsitencies with the generation because I tried multiple times and I always get the same output. I am not sure why the ci is generating something different.

Another reason a lot of things are bunched in the general module is that Linux headers often pull in other Linux headers, so it's difficult to get clearly scoped modules that just have headers for one purpose and not also all their transitive header dependencies. Because if every module has its dependencies, we'd end up with a lot of duplication. I imagine one way forward is to make more use of bindgen's ability to filter out symbols by things like prefix names. That won't always work (as in the AT_ case here), but could help in many cases.

Contributing a few times to this project made me realize we could make much better use of bindgen features and refactor the codegen a lot. I was planning to work on something of that nature but I am still unsure on what the best approach is.

@morr0ne
Copy link
Contributor Author

morr0ne commented Sep 9, 2025

I rebased to main and regenerated the bindings. Hopefully it should work now. It also seems I have caught some stray changes from a previous pr that wasn't correctly updated

@sunfishcode
Copy link
Owner

The bindgen output seems to be sensitive to the version of clang installed. The CI is using clang-22.

@sunfishcode
Copy link
Owner

On further consideration, I think this makes enough sense that I'm just going to merge it and regenerate the files separately.

@sunfishcode sunfishcode merged commit 942862c into sunfishcode:main Sep 9, 2025
4 of 5 checks passed
@sunfishcode
Copy link
Owner

This is now released in linux-raw-sys 0.11.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants